<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
	.tree-node {padding:0;}
	img {
		height:50px;
		width:50px;
	}
</style>
<script type="text/javascript">
	$(function() {
		$('#toolbar_articleTable').toolbar({buttons:[
           	{name:'add',iconCls:'icon-add',text:'添加项目'},
       		{name:'reload',iconCls:'icon-reload',text:'刷新'}
      	],handler:handler});
		$('#category_datagrid_toolbar').toolbar({buttons:[
           	{name:'save_category',iconCls:'icon-ok',text:'投稿'},
      	],handler:handler});
		
	    $('#article_datagrid').datagrid({
	    	url:'page',
    		pagination:true,
    		pageSize:20,
    		singleSelect:true,
    		rownumbers:false,
    		striped:true,
    		fit:true,
    		fitColumns:true,
    		toorbar:'#toolbar_articleTable',
    		columns:[[
    			{field:'id',title:'编号'},
    			{field:'projectName',title:'项目名称'},
        		{field:'proStatus',title:'状态',formatter:function(v,r,i){
        			var type ="";
        			if(v == "0"){
        				type ="正常"
        			}else if(v == "1"){
        				type ="删除"
        			}else if(v == "2"){
        				type="未开始"
        			}else if(v == "3"){
        				type="进行中"
        			}else if(v == "4"){
        				type="已逾期"
        			}else if(v == "5"){
        				type="已结束"
        			}
        			return type;
        		}},
        		{field:'belongUserName',title:'所有人'},
        		{field:'createTime',title:'创建时间'},
        		{field:'-',title:'操作',align:'center',formatter:function(v,r,i){
        			var action = '<a href="#" onclick="toEdit('+r.id+');">编辑</a>&nbsp;&nbsp;';
        			/* if(r.enabled){
        				action = action+'<a href="#" onclick ="enabled('+r.id+');">禁用</a>';
        				if(r.categoryId < 1){
        					action = action+'&nbsp;&nbsp;<a href="#" onclick="addCategory('+i+');">去投稿</a>';
        				}
        			}else{
        				action = action+'<a href="#" onclick="disbled('+r.id+');">启用</a>';
        				
        			} */
        			action = action+'&nbsp;&nbsp;<a href="#" onclick="del('+r.id+');">删除</a>';
        			
					return action;
				}}
    		]],
    		view: detailview,
    	    detailFormatter: function(rowIndex, rowData){
    	        return '<table><tr>' +
    	                '<td rowspan=2 style="border:0,height:50px;">'+rowData.articleContent+'</td>' +
    	                '</tr></table>';
    	    }
		 });
		
		function handler() {
			switch(this.name) {
				case 'add': toAdd();break;
				
				case 'save_category': saveCategory();break;
			}
		}
		function toAdd(type) {
			show({code:'degua_add',title:'添加项目',iconCls:'icon-add',uri:'add',width:800,height:800,
				options : {
					success : function(data) { 
						$('#article_datagrid').datagrid('reload'); 
					}
				}
			});
		}

	
	$("#a_searchTag").click(function(){
		reloadDate();
	});
	$("#a_clearn").click(function(){
		resetData();
	});
		
		function reloadDate(){
			var item = getItem();
			$('#article_datagrid').datagrid({ queryParams: item});   //点击搜索
		}
		function resetData(){
			$("#search_user").textbox("setValue","");
			$("#search_articleTitle").textbox("setValue","");
			$("#search_articleType").combobox("setValue","");
			$("#search_enabled").combobox("setValue","");
			reloadDate();
		}
	});
	
	function del(id){
		$.messager.confirm('提示', '是否删除', function(r){
			if (r){
				$.post("delete",{"id":id},function(data) {
					$('#article_datagrid').datagrid('reload'); 
				});
			}
		});
	}
	
	//编辑
	function toEdit(item) {
		show({code:'tag_info_edit',title:'编辑文章信息',iconCls:'icon-edit',uri:'edit?id='+item,width:900,height:900,
			options : {
				success : function(data) { 
					$('#article_datagrid').datagrid('reload'); 
				}
			}
		});
	}
	//查看详细
	function detail(item){
		show({code:'tag_info_detail',title:'文章信息',iconCls:'icon-edit',uri:'detail?id='+item,width:900,height:900,
			options : {
				success : function(data) { 
					$('#article_datagrid').datagrid('reload'); 
				}
			}
		});
	}
	

</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true">
  		<div data-options="region:'center',border:false" style="padding-bottom: 33px">
            <div id="toolbar_articleTable" class="toolbar"></div>
  			<table id="article_datagrid"></table>
		</div>
		
		<div id="dialog_category" class="easyui-dialog" data-options="closed:true," title="投稿到" style="width:600px;height:300px;padding:10px">
			<div id="category_datagrid_toolbar" class="toolbar" ></div>
			<table id="category_datagrid" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,pagination:true,url:'/category/info/page',method:'post'">
				<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th data-options="field:'id',width:80">编号</th>
						<th data-options="field:'name',width:100">栏目名称</th>
						<th data-options="field:'note',width:80,align:'right'">备注</th>
					</tr>
				</thead>
			</table>
		</div>
		<div id="dialog_articleType" class="easyui-dialog" data-options="closed:true," title="选择添加文章的类型" style="width:280px;height:180px;padding:10px">
			<table>
				<tr>
					<td><a href="#" id="type_article" onclick="addTypeText();" class="easyui-linkbutton c1" style="width:120px;height: 50px;">图文</a></td>
					<td><a href="#" id="type_sound" onclick="addTypeSound();" class="easyui-linkbutton c2" style="width:120px;height: 50px;">音频</a></td>
				</tr>
				<tr>
					<td><a href="#" id="type_pk" onclick="addTypePk();" class="easyui-linkbutton c3" style="width:120px;height: 50px;">话题pk</a></td>
					<td><a href="#" id="type_movie" onclick="addTypeMovie();" class="easyui-linkbutton c4" style="width:120px;height: 50px;">视频</a></td>
				</tr>
			</table>
		</div>
	</div>
</body>
</html>